﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Schism.Core;
using Schism.libs;
using Ivory;

namespace Schism.Mapping
{
    [Serializable]
    public abstract class CellBase : IViewableController
    {
        //Fields  
        [NonSerialized]
        public Texture2D WallTexture;
        public DungeonPos MapPosition;

        public abstract bool IsWalkable { get; }
        
        //Ctor
        public CellBase(DungeonPos pos)
        {
            this.MapPosition = pos;
        }

        //Methods
        protected virtual int OnMine() { return 0; }
        public int Mine()
        {
            return OnMine();
        }
        
        protected abstract void DrawCell(SpriteBatch batch, GameTime time);
        protected abstract void SolveCell(InputControl control, GameTime time);
        
        protected virtual bool InitalizeCell() { return true; }
        protected virtual bool LoadCell() { return true; }

        public void Render(SpriteBatch batch, GameTime time)
        {
            DrawCell(batch, time);
        }
        public void Solve(InputControl control, GameTime time)
        {
            SolveCell(control, time);
        }

        public bool Initalize()
        {
            return true;
        }
        public bool Load()
        {
            return true;
        }
    }
}
